﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt.mssql
{
	// Token: 0x0200016A RID: 362
	public class TMssqlCreateTrigger : TStoredProcedureSqlStatement
	{
		// Token: 0x06000C7A RID: 3194 RVA: 0x00307756 File Offset: 0x00305956
		public TMssqlCreateTrigger(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstmssqlcreatetrigger;
		}

		// Token: 0x06000C7B RID: 3195 RVA: 0x00307767 File Offset: 0x00305967
		internal override void buildsql()
		{
		}

		// Token: 0x06000C7C RID: 3196 RVA: 0x00307769 File Offset: 0x00305969
		internal override void clear()
		{
		}

		// Token: 0x06000C7D RID: 3197 RVA: 0x0030776B File Offset: 0x0030596B
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000C7E RID: 3198 RVA: 0x00307772 File Offset: 0x00305972
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x1700024A RID: 586
		// (get) Token: 0x06000C80 RID: 3200 RVA: 0x0030777D File Offset: 0x0030597D
		// (set) Token: 0x06000C7F RID: 3199 RVA: 0x00307774 File Offset: 0x00305974
		public virtual bool AlterTrigger
		{
			get
			{
				return this.alterTrigger;
			}
			set
			{
				this.alterTrigger = value;
			}
		}

		// Token: 0x1700024B RID: 587
		// (get) Token: 0x06000C81 RID: 3201 RVA: 0x00307785 File Offset: 0x00305985
		public override TObjectName StoredProcedureName
		{
			get
			{
				return this.triggerName;
			}
		}

		// Token: 0x1700024C RID: 588
		// (get) Token: 0x06000C82 RID: 3202 RVA: 0x0030778D File Offset: 0x0030598D
		// (set) Token: 0x06000C83 RID: 3203 RVA: 0x00307795 File Offset: 0x00305995
		public virtual TTable OnTable
		{
			get
			{
				return this.onTable;
			}
			set
			{
				this.onTable = value;
			}
		}

		// Token: 0x1700024D RID: 589
		// (get) Token: 0x06000C84 RID: 3204 RVA: 0x0030779E File Offset: 0x0030599E
		// (set) Token: 0x06000C85 RID: 3205 RVA: 0x003077A6 File Offset: 0x003059A6
		public virtual TObjectName TriggerName
		{
			get
			{
				return this.triggerName;
			}
			set
			{
				this.triggerName = value;
			}
		}

		// Token: 0x1700024E RID: 590
		// (get) Token: 0x06000C87 RID: 3207 RVA: 0x003077B8 File Offset: 0x003059B8
		// (set) Token: 0x06000C86 RID: 3206 RVA: 0x003077AF File Offset: 0x003059AF
		public virtual ETriggerTimingPoint TimingPoint
		{
			get
			{
				return this.timingPoint;
			}
			set
			{
				this.timingPoint = value;
			}
		}

		// Token: 0x1700024F RID: 591
		// (get) Token: 0x06000C89 RID: 3209 RVA: 0x003077C9 File Offset: 0x003059C9
		// (set) Token: 0x06000C88 RID: 3208 RVA: 0x003077C0 File Offset: 0x003059C0
		public virtual ETriggerDmlType DmlTypes
		{
			get
			{
				return this.dmlTypes;
			}
			set
			{
				this.dmlTypes = value;
			}
		}

		// Token: 0x06000C8A RID: 3210 RVA: 0x003077D4 File Offset: 0x003059D4
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			if (!(this.rootNode is TCreateTriggerSqlNode))
			{
				return -1;
			}
			TCreateTriggerSqlNode tcreateTriggerSqlNode = (TCreateTriggerSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.triggerName = tcreateTriggerSqlNode.TriggerName;
			base.DatabaseObjects.Add(this.triggerName);
			this.alterTrigger = tcreateTriggerSqlNode.AlterTrigger;
			this.fireMode = tcreateTriggerSqlNode.FireMode;
			this.timingPoint = tcreateTriggerSqlNode.TimingPoint;
			this.onTable = tcreateTriggerSqlNode.OnTable;
			this.onTable.EffectType = ETableEffectType.tetTriggerOn;
			this.tables.addTable(this.onTable);
			for (int i = 0; i < tcreateTriggerSqlNode.DmlTpyes.size(); i++)
			{
				if (tcreateTriggerSqlNode.DmlTpyes.getDummyItem(i).st1.ToString().Equals("insert", StringComparison.CurrentCultureIgnoreCase))
				{
					this.dmlTypes |= ETriggerDmlType.tdtInsert;
				}
				else if (tcreateTriggerSqlNode.DmlTpyes.getDummyItem(i).st1.ToString().Equals("delete", StringComparison.CurrentCultureIgnoreCase))
				{
					this.dmlTypes |= ETriggerDmlType.tdtDelete;
				}
				else if (tcreateTriggerSqlNode.DmlTpyes.getDummyItem(i).st1.ToString().Equals("update", StringComparison.CurrentCultureIgnoreCase))
				{
					this.dmlTypes |= ETriggerDmlType.tdtUpdate;
				}
				else
				{
					this.dmlTypes |= ETriggerDmlType.tdtEvent;
				}
			}
			if (tcreateTriggerSqlNode.Stmts != null)
			{
				tcreateTriggerSqlNode.Stmts.doParse(this, ESqlClause.unknown);
				for (int j = 0; j < tcreateTriggerSqlNode.Stmts.size(); j++)
				{
					this.BodyStatements.add(tcreateTriggerSqlNode.Stmts.getStatementSqlNode(j).Stmt);
				}
			}
			return 0;
		}

		// Token: 0x17000250 RID: 592
		// (get) Token: 0x06000C8B RID: 3211 RVA: 0x00307984 File Offset: 0x00305B84
		// (set) Token: 0x06000C8C RID: 3212 RVA: 0x0030798C File Offset: 0x00305B8C
		public virtual int FireMode
		{
			get
			{
				return this.fireMode;
			}
			set
			{
				this.fireMode = value;
			}
		}

		// Token: 0x06000C8D RID: 3213 RVA: 0x00307995 File Offset: 0x00305B95
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000C8E RID: 3214 RVA: 0x003079A5 File Offset: 0x00305BA5
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.BodyStatements.size() > 0)
			{
				this.BodyStatements.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x040012E3 RID: 4835
		private bool alterTrigger;

		// Token: 0x040012E4 RID: 4836
		private TTable onTable;

		// Token: 0x040012E5 RID: 4837
		private TObjectName triggerName;

		// Token: 0x040012E6 RID: 4838
		private int fireMode;

		// Token: 0x040012E7 RID: 4839
		private ETriggerTimingPoint timingPoint;

		// Token: 0x040012E8 RID: 4840
		private ETriggerDmlType dmlTypes;
	}
}
